﻿
<script>
    var _hmt = _hmt || [];
    (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?0f6cf47be44656da3509fd42049dbe38";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>

<div class="micronews-header-wrap">
    <div style="max-width:1000px; margin: 0 auto;" class="micronews-header w1000 layui-clear">
        <h1 class="logo">
            <a href="/">
                <img src="~/Content/wenews/images/LOGO.png" alt="logo">
                <span class="layui-hide">LOGO</span>
            </a>
        </h1>
        <p class="nav">
            <a href="/?pt=2&idx=1&ps=8" id="nav2">证券</a>
            <a href="/?pt=3&idx=1&ps=10" id="nav3">娱乐</a>
            <a href="/?pt=4&idx=1&ps=8" id="nav4">科技</a>
            <a href="/?pt=5&idx=1&ps=10" id="nav5">国际</a>
            <a href="/?pt=6&idx=1&ps=10" id="nav6">军事</a>
            <a href="/?pt=7&idx=1&ps=10" id="nav7">汽车</a>
        </p>
        <div class="search-bar">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        @if (!string.IsNullOrEmpty(ViewBag.KeyWord))
                        {
                            <input type="text" name="title" placeholder="" value="@ViewBag.KeyWord" autocomplete="off" class="layui-input">
                        }
                        else
                        {
                            <input type="text" name="title" placeholder="搜索你要的内容" autocomplete="off" class="layui-input">
                        }
                        <button class="layui-btn search-btn" formnovalidate><i class="layui-icon layui-icon-search"></i></button>
                    </div>
                </div>
            </form>
        </div>
        <div class="login">
            <a href="/Login/Index">
                登录
            </a>
            <!-- <a href="login.html"> -->
            <!-- <img src="images/images/header.png" style="width: 36px; height: 36px;"> -->
            <!-- </a> -->
        </div>
        <div class="menu-icon">
            <i class="layui-icon layui-icon-more-vertical"></i>
        </div>
        <div class="mobile-nav">
            <ul class="layui-nav" lay-filter="">
                <li class="layui-nav-item layui-this"><a href="/">最新</a></li>
                <li class="layui-nav-item"><a href="/">娱乐</a></li>
                <li class="layui-nav-item"><a href="/">生活</a></li>
                <li class="layui-nav-item"><a href="/">财经</a></li>
                <li class="layui-nav-item"><a href="/">科技</a></li>
                <li class="layui-nav-item"><a href="/">军事</a></li>
            </ul>
        </div>
    </div>
</div>


<script type="text/javascript">
    var index;
    layui.config({ base: '/Scripts/wenews/' }).use('index', function () {
        index = layui.index;
    });

    $(function () {
        setActiveClass();
        $("#popWechat").click(function () {
            index.popWechat();
        });

    });


    function setActiveClass() {
        //javascript使用后端变量
        var page = '@ViewBag.Page';
        if (page == "Details") {
            setNavClass("");
        }
        else {
            var obj = getRequest();
            if (!obj.pt) {
                setNavClass("nav2");
            }
            switch (obj.pt) {
                case "2":
                    setNavClass("nav2");
                    break;
                case "3":
                    setNavClass("nav3");
                    break;
                case "4":
                    setNavClass("nav4");
                    break;
                case "5":
                    setNavClass("nav5");
                    break;
                case "6":
                    setNavClass("nav6");
                    break;
                case "7":
                    setNavClass("nav7");
                    break;
                default:
                    setNavClass("nav2");
                    break;
            }
        }
    }

    function setNavClass(id) {
        var arr = new Array("nav2", "nav3", "nav4", "nav5", "nav6", "nav7");
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] == id) {
                $("#" + id).addClass("active");
            }
            else {
                $(arr[i]).removeClass("active");
            }
        }


    }

    //获取url参数
    function getRequest() {
        var url = location.search; //获取url中"?"符后的字串
        url = url.substr(url.lastIndexOf('?'));
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }

</script>